<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./art-template.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .box {
            margin: 50px auto;
            width: 1000px;
            height: 1000px;
            border: 1px solid #000;
            overflow: hidden;
        }

        .box ul {
            display: flex;
            justify-content: flex-start;
            flex-wrap: wrap;
        }

        .box ul li {
            margin-top: 24px;
            margin-left: 23px;
            height: 300px;
            width: 300px;
            border: 1px solid #000;
            overflow: hidden;
        }

        img {
            width: 300px;
        }

        #aaa {
            width: 300px;
            height: 300px;
        }

        .ipt {
            background-image: url(./+.png);
            background-size: 300px;
        }

        input {
            opacity: 0;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li class="ipt">
                <form action="">
                    <input type="file" id="aaa" name="img" multiple />
                </form>
            </li>
        </ul>
    </div>
    <script id="con" type="text/html">
    {{each res as item}}
        <li>
            <img src={{item}} alt="">
        </li>
    {{/each}}
    </script>
    <script>
        var input = document.querySelector('#aaa');
        var box = document.querySelector('div.box');
        var ul = document.querySelector('ul');
        var ipt = document.querySelector(".ipt")
        var res = [];
        input.addEventListener('change', function () {
            // console.log(this.files);
            res = [];
            for (let i = 0; i < this.files.length; i++) {
                res.push(URL.createObjectURL(this.files[i]));
            }
            var resobj = {
                res,
            }
            var str = template("con", resobj);
            ipt.insertAdjacentHTML('beforeBegin', str);
            var lis = document.querySelectorAll('li');
            for (let i = 0; i < lis.length; i++) {
                lis[i].ondblclick = function () {
                    console.log(111);
                    this.remove();
                }
            }
        })

    </script>
</body>

</html>